<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .basic{
            text-align: center;
        }
        .happy{
            background-color: #8d4f3c;
        }
        .sad{
            background-color: bisque;
        }
        .normal{
            background-color: #34628d;
        }

    </style>
</head>
<body>
    <div id="root">
        <!--绑定class样式 字符串写法，适用于：样式类名不确定，需要动态指定-->
        <div class="basic" :class="mood" @click="changeMood">{{name}}</div><br>

    </div>
    <script src="../js/vue.js"></script>
    <script>
            Vue.config.productionTip=false//阻止vue启动时产生提示
            new Vue({
                 el: "#root",
                 data:{//数据
                     name:'cljh',
                     mood:"normal"
                    },
                 methods:{//方法
                     changeMood(){
                         const arr=['happy','sad','normal']
                         var index = Math.floor(Math.random()*3);//向下取整0-3
                         this.mood=arr[index]
                     }
                 },
                 computed:{//计算

                 },
                 watch:{//监视

                 }
             })
    </script>
</body>
</html>